package com.yxuan.springboot.controller;


import com.yxuan.springboot.mapper.OrdersMapper;
import com.yxuan.springboot.mapper.UserLoginMapper;
import com.yxuan.springboot.util.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;

import static com.yxuan.springboot.util.Code.SUCCESSCODE;

@RestController
@Slf4j
@RequestMapping("/kanban")
public class KanbanController {



    @Autowired
    private OrdersMapper ordersMapper;

    @Autowired
    private UserLoginMapper userLoginMapper;

    /**
     * 已支付总金额
     */
    @RequestMapping("/totalAmount")
    public Result totalAmount() throws Exception {

        HashMap<String, Object> map = new HashMap<>();
        map.put("totalAmount",ordersMapper.findTotalAmount());

        return new Result(map,SUCCESSCODE);
    }

    /**
     * 今日支付总金额
     */
    @RequestMapping("/todayTotalAmount")
    public Result todayTotalAmount() throws Exception {

        HashMap<String, Object> map = new HashMap<>();
        map.put("todayTotalAmount",ordersMapper.findTodayTotalAmount());

        return new Result(map,SUCCESSCODE);
    }

    /**
     * 今日注册人数
     */
    @RequestMapping("/todayRegisterNumber")
    public Result todayRegisterNumber() throws Exception {


        HashMap<String, Object> map = new HashMap<>();

        map.put("todayRegisterNumber",userLoginMapper.findTodayRegisterNumber());

        return new Result(map,SUCCESSCODE);


    }


    /**
     * 各省注册人数
     */
    @RequestMapping("/provincialRegisterNumber")
    public Result provincialRegisterNumber() throws Exception {


        return new Result(userLoginMapper.findProvincialRegisterNumber(),SUCCESSCODE);


    }

    /**
     * 最近15天每一天的收入
     */
    @RequestMapping("/fifteenIncome")
    public Result fifteenIncome() throws Exception {


        return new Result(ordersMapper.fifteenIncome(),SUCCESSCODE);


    }


    /**
     * 最近15天每一天注册人数
     */
    @RequestMapping("/fifteenRegisterNumber")
    public Result fifteenRegisterNumber() throws Exception {


        return new Result(userLoginMapper.fifteenRegisterNumber(),SUCCESSCODE);


    }


    /**
     * 查看今日付费总人数
     */
    @RequestMapping("/todayConsumerNumber")
    public Result todayConsumerNumber() throws Exception {

        HashMap<String, Object> map = new HashMap<>();

        map.put("todayRegisterNumber",ordersMapper.findTodayConsumerNumber());

        return new Result(map,SUCCESSCODE);





    }

}
